package com.chenliang.sc.filter;


import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

import javax.servlet.*;
import java.io.IOException;

/**
 * @program: springcase
 * @description: 过滤器实现3:自定义过滤器类+配置类实现,配置都在配置类进行配置
 * @author: 陈亮
 * @create: 2022-06-09 17:58
 */
@ConditionalOnProperty(
        prefix = "config",
        name = {"filter.open"},
        havingValue = "true",
        matchIfMissing = false
)
public class MyFilter03 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("容器启动:初始化MyFilter03");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("MyFilter03.doFilter()执行");
        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {
        System.out.println("容器销毁:MyFilter03.destroy()执行");
    }
}
